<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="cHead" ContentPlaceHolderID="cphHead" runat="server">
    <% this.Page.Title = (string)ViewData["PageTitle"]; %>
</asp:Content>

<asp:Content ID="cBreadCrumb" runat="server" ContentPlaceHolderID="cphBreadCrumb">
    <div id="infoBread">
        <%= Html.ActionLink("Changer de mot de passe", "ChangePassword", new { controller = "Profil" })%>
    </div>
</asp:Content>

<asp:Content ID="cJScripts" ContentPlaceHolderID="cphJScripts" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            // Text Lenght
            var mlength = 255;
            $("#signature").keyup(function () {
                if ($(this).val().length > mlength) {
                    $(this).val($(this).val().substring(0, mlength));
                }
                $('#charRest').text($(this).val().length + ' / ' + mlength);
            });
            $("#charRest").text($("#signature").val().length + ' / ' + mlength);

            // Change Display
            $("#SlFunctions").change(function () {
                (this.selectedIndex == 1 || this.selectedIndex == 2) ? $("#selectSection").show("normal") : $("#selectSection").hide("normal");
            });

            ($("#SlFunctions")[0].selectedIndex == 1 || $("#SlFunctions")[0].selectedIndex == 2) ? $("#selectSection").show("normal") : $("#selectSection").hide("normal");

            $("#deleteItem").colorbox({ width: "400px", height: "170px", iframe: true, title: "Supprimer l'avatar" });

            $("a.green").click(function () {
                if ($("#SlFunctions")[0].selectedIndex != 1 && $("#SlFunctions")[0].selectedIndex != 2) {
                    $("#selectSection").val("");
                }
                $(this).addClass("loading");
                $('#inscription form:eq(0)').submit();
            });

            $("a.blue").click(function () {
                $('#inscription form')[0].reset();
            });
        });
        
        function DeleteAvatar(avatarID){
            $.ajax({
                type: "POST",
                url: "/Profil/DeleteAvatar",
                data: 'AID=' + avatarID
            });
        }
    </script>
</asp:Content>

<asp:Content ID="cMainContent" ContentPlaceHolderID="cphMainContent" runat="server">
<div id="inscription">
    <%= Html.ValidationSummary(ScoutNET.Resources.Master_Form_ErrorMessage)%>

    <% using (Html.BeginForm("Index", "Profil", FormMethod.Post, new { enctype = "multipart/form-data" })) { %>
        <h1> <%= ScoutNET.Resources.Profil_Inscription_Title1 %> : </h1>
        
        <p>
            <label for="firstname"> <%= ScoutNET.Resources.Profil_Inscription_Firstname %> :</label>
            <%= Html.TextBox("firstname", null, new { @class = "small" })%>
        </p>
        <p>
            <label for="lastname"> <%= ScoutNET.Resources.Profil_Inscription_Lastname %> :</label>
            <%= Html.TextBox("lastname", null, new { @class = "small" })%>
        </p>
        <p>
            <label for="email"> <%= ScoutNET.Resources.Profil_Inscription_Email %> :</label>
            <%= Html.TextBox("email", null, new { @class = "small" })%>
        </p>
        

	    <div class="hr1">&nbsp;</div> 
	    <h1> <%= ScoutNET.Resources.Profil_Inscription_Title2 %> : </h1>
        <p><strong> <%= ScoutNET.Resources.Profil_Inscription_Subtitle1 %></strong></p>
        <% foreach (tSite_Section item in (List<tSite_Section>)ViewData["lSections"]){ %>
            <% string selected = (((List<tSite_Section>)ViewData["lUserSections"]).Where(p => p.ID == item.ID).Count() > 0) ? "checked=\"checked\"" : string.Empty; %>
            <div class="blockINscription"><p><label for="section<%= item.ID %>"><%= item.Section %> : </label><input type="checkbox" id="section<%= item.ID %>" name="infoSection" value="<%= item.ID %>" <%= selected %> /></p></div>
        <% } %>	
        <div class="clr"></div>
        
        <p><strong> <%= ScoutNET.Resources.Profil_Inscription_Subtitle2 %></strong></p>
	    <p>
		    <label for="SlSection"> <%= ScoutNET.Resources.Profil_Inscription_SlFunctions %> :</label>
		    <%= Html.DropDownList("SlFunctions")%>
	    </p>
		
	    <p id="selectSection" class="display">
		    <label for="SlSection"> <%= ScoutNET.Resources.Profil_Inscription_SlSection %> :</label>
		    <%= Html.DropDownList("SlSection")%>
	    </p>
		
	    <div class="hr1"></div> 
		
	    <h1> <%= ScoutNET.Resources.Profil_Inscription_Title3 %> : </h1>
		
	    <p>
	        <label for="sex" title="Sexe"> <%= ScoutNET.Resources.Profil_Inscription_Sex %> :</label>
             <%= ScoutNET.Resources.Profil_Inscription_SexF %> : <%= Html.RadioButton("sex", "F", (bool)ViewData["sexF"])%>
		     <%= ScoutNET.Resources.Profil_Inscription_SexM %> : <%= Html.RadioButton("sex", "M", (bool)ViewData["sexM"])%>
        </p>
        <p>
            <label for="totem"> <%= ScoutNET.Resources.Profil_Inscription_Totem %> :</label>
            <%= Html.TextBox("totem", null, new { @class = "small" })%>
        </p>
        <p>
            <label for="avatar"> <%= ScoutNET.Resources.Profil_Inscription_Avatar %> :</label>
            <%= Html.FileUpload("avatar")%>
            <%= Html.ValidationMessage("avatar")%>
            <% if (ViewData["avatar"] != string.Empty) { %>
            <span id="avatarTool">
                <a class="tt" href="javascript:void(0);">
                    Ton avatar actuel
                    <span class="ttContent">
                        <span class="top">&nbsp;</span>
                        <span class="middle">
                            <img alt="" src="<%= ViewData["avatar"] %>"/>
                        </span>
                        <span class="bottom">&nbsp;</span>
                    </span>
                </a>
                | <%= Html.ActionLink("Supprimer", "DeleteAvatar", new{controller = "Profil", id = ViewData["avatarID"]}, new {id = "deleteItem" })%>
            </span>
            <% } %>
        </p>
        <p>
            <label for="location"> <%= ScoutNET.Resources.Profil_Inscription_Location %> :</label>
            <%= Html.TextBox("location", null, new { @class = "small" })%>
        </p>
        <p>
            <label for="phone"> <%= ScoutNET.Resources.Profil_Inscription_Phone %> * :</label>
            <%= Html.TextBox("phone", null, new { @class = "little", maxlength = "13" })%>
            <%= ScoutNET.Resources.Profil_Inscription_Com_Phone %>
        </p>
        
        <p>
            <label for="webSite"> <%= ScoutNET.Resources.Profil_Inscription_WebSite %> :</label>
            <%= Html.TextBox("webSite", null, new { @class = "small", })%>
            <%= ScoutNET.Resources.Profil_Inscription_Com_WebSite %>
        </p>
        
        <p>
            <label for="signature"> <%= ScoutNET.Resources.Profil_Inscription_Signature %> :<br /><span id="charRest"><%= ((string)ViewData["signature"]).Length.ToString() %> / 255</span></label>
            <%= Html.TextArea("signature", null, new { @class = "textAreaSmall", cols="30", rows="5", maxlength = "255" })%>
        </p>

        <div class="blockButton">
	        <a class="mediumBtn green awesome" href="javascript:void(0);" title="<%= ScoutNET.Resources.Master_Button_Edit %>" id="submit"><%= ScoutNET.Resources.Master_Button_Edit %></a>
            <a class="mediumBtn blue awesome" href="javascript:void(0);" id="reset" title="<%= ScoutNET.Resources.Master_Button_Reset %>"><%= ScoutNET.Resources.Master_Button_Reset %></a>
        </div>

    <% } %>
</div>
</asp:Content>
